#pragma once
#include<iostream>
#include<assert.h>
using namespace std;
class Date {
	friend ostream& operator<<(ostream& out, const Date& d);
	friend istream& operator>>(istream& in,  Date& d);
public:
	bool CheckDate() {
		if ((_month > 0 && _month < 13) && (_day > 0 && _day < GetMonthDay()))
			return true;
		else
			return false;
	}
	Date(int year=2024, int month=9, int day=15)
		:_year(year)
		,_month(month)
		,_day(day)
	{}
	int GetMonthDay() {
		assert(_month > 0 && _month < 13);
		static int MonthDay[13] = { -1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
		if (_month == 2 && ((_year % 4 == 0 && _year % 100 != 0) || (_year % 400 == 0))) {
			return 29;
		}
		return MonthDay[_month];
	}
	void print() {
		cout << _year << ' ' << _month << ' ' << _day << endl;
	}
	bool operator<(const Date& d)const;
	bool operator<=(const Date& d)const;
	bool operator>(const Date& d)const;
	bool operator>=(const Date& d)const;
	bool operator==(const Date& d)const;
	bool operator!=(const Date& d)const;
	Date& operator+=(const int day);
	Date operator+(const int day)const;
	Date& operator-=(const int day);
	Date operator-(const int day)const;
	int operator-(const Date& d)const;
	Date operator++(int);
	Date operator--(int);
	Date& operator++();
	Date& operator--();

private:
	int _year;
	int _month;
	int _day;
};
ostream& operator<<(ostream& out, const Date& d);
istream& operator>>(istream& in, const Date& d);